#define _CRT_SECURE_NO_WARNINGS 1
#include<stdio.h>
void get_max(int x, int y)
{
	int x1=0, y1=0;
	if (x > y)
	{
		x1 = x;
		y1 = y;
	}
	else
	{
		x1 = y;
		y1 = x;
	}
	int m = x1 % y1;
	if (m == 0)
	{
		printf("%d", y1);
	}
	else {
		x1 = y1;
		y1 = m;
		get_max(x1, y1);

	}
}
int main()
{
	int a = 0;
	int b = 0;
	scanf("%d %d", &a, &b);
	get_max(a, b);
	return 0;
}